package com.online.music.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.online.music.common.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import com.online.music.service.ILyricsService;
import com.online.music.entity.po.Lyrics;

import org.springframework.web.bind.annotation.RestController;


/**
 * @Author: Leno
 * @Date: 2025-01-31
 * @Description: lyrics接口
 */
@RequiredArgsConstructor
@Slf4j
@Tag(name = "lyrics接口")
@RestController
@RequestMapping("/lyrics")
public class LyricsController {

    private final ILyricsService lyricsService;

    @Operation(summary = "查询所有Lyrics")
    @GetMapping
    public Result<List<Lyrics>> findAll() {
        return Result.success(lyricsService.list());
    }

    @Operation(summary = "根据id查询Lyrics")
    @GetMapping("/{id}")
    public Result<Lyrics> findOne(@PathVariable Long id) {
        return Result.success(lyricsService.getById(id));
    }

    @Operation(summary = "根据分页查询Lyrics")
    @GetMapping("/page")
    public Result<Page<Lyrics>> findPage(@RequestParam Integer pageNum, @RequestParam Integer pageSize, Lyrics lyrics) {
        return lyricsService.findPage(pageNum, pageSize, lyrics);
    }

    @Operation(summary = "添加或修改Lyrics")
    @PostMapping
    public Result<Boolean> save(@RequestBody Lyrics lyrics) {
        return Result.success(lyricsService.saveOrUpdate(lyrics));
    }

    @Operation(summary = "根据id批量删除Lyrics")
    @DeleteMapping("/del/batch")
    public Result<String> deleteBatch(@RequestBody List<Long> ids) {
        return lyricsService.deleteBatch(ids);
    }

}
